#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <string.h>



int main()

{

int arr[10000] = { 0 };

int L = 0, M = 0, i = 0, j = 0,count = 0;

int arr1[100][2] = { 0 };

scanf("%d%d", &L, &M);

for (i = 0;i <= L; i++)

{

arr[i] = 1;

}

for (i = 0;i < M; i++)

{

scanf("%d%d", &arr1[i][0], &arr1[i][1]);

}

for (i = 0;i < M;i++)

{

for (j = arr1[i][0];j <= arr1[i][1];j++)

{

arr[j] = 0;

}

}

for (i = 0;i <= L;i++)

{

if (arr[i] == 1)

{

count++;

}

}

printf("%d", count);

return 0;

}
